* PDF maker: format screen and input same. Shrink padding slightly.
* Use reference counted pointers instead of managing our own.
Fixes a leak when using debug printing.
* Remove the last remaining caller of xstrappend and thus, that c-era utility.
Co-authored-by: Robert Lipe <robertlipe@users.noreply.github.com>
void xfree(const void* mem);
char* xstrdup(const QString& s);
char* xstrndup(const char* str, size_t sz);
-char* xstrappend(char* src, const char* newd);
char* xstrdup(const char* s);
FILE* xfopen(const char* fname, const char* type, const char* errtxt);
gbfread(b.get(), 1, sz, fin);
fprintf(stderr, "\n");
for (x = 0; x < sz; x++) {
- fprintf(stderr, "%02x ", b[x]);
+ fprintf(stderr, "%02x ", b[x]);
}
fprintf(stderr, "\n");
for (x = 0; x < sz; x++) {
- fprintf(stderr, "%c", isalnum(b[x]) ? b[x] : '.');
+ fprintf(stderr, "%c", isalnum(b[x]) ? b[x] : '.');
}
fprintf(stderr, "\n");
}
static void
init_date_and_time_format()
{
- const char* f = get_option_val(opt_date_format, DEFAULT_DATE_FORMAT);
- date_time_format = convert_human_date_format(f);
+ // This is old, and weird, code.. date_time_format is a global that's
+ // explicitly malloced and freed elsewhere. This isn't very C++ at all,
+ // but this format is on its deathbead for deprecation.
+ const char* d = get_option_val(opt_date_format, DEFAULT_DATE_FORMAT);
+ char* d1 = convert_human_date_format(d);
- date_time_format = xstrappend(date_time_format, " ");
+ const char* t = get_option_val(opt_time_format, DEFAULT_TIME_FORMAT);
+ char* t1 = convert_human_time_format(t);
- f = get_option_val(opt_time_format, DEFAULT_TIME_FORMAT);
- const char* c = convert_human_time_format(f);
- date_time_format = xstrappend(date_time_format, c);
- xfree((void*) c);
+ xasprintf(&date_time_format, "%s %s", d1, t1);
+
+ xfree(d1);
+ xfree(t1);
}
static void
return o;
}
-/*
-* For an allocated string, realloc it and append 's'
-*/
-char*
-xstrappend(char* src, const char* newd)
-{
- if (!src) {
- return xstrdup(newd);
- }
- if (!newd) {
- return xstrdup(src);
- }
-
- size_t newsz = strlen(src) + strlen(newd) + 1;
- src = (char*) xrealloc(src, newsz);
- strcat(src, newd);
-
- return src;
-}
-
/*
* Wrapper for open that honours - for stdin, stdout, unifies error text.
*/